﻿// HSS.ServiceModel.Internal.VirtualUtilities.cs
// ----------------------------------------------------------------------------
// Licensed under the MIT license
// http://www.opensource.org/licenses/mit-license.html
// ----------------------------------------------------------------------------
// HighSpeed-Solutions, LLC
// Copyright (c) 2001-2010
// ----------------------------------------------------------------------------
// File:       VirtualUtilities.cs
// Author:     HSS\gbanta
// Created:    08/12/2010
// Modified:   12/04/2010
// ----------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HSS.ServiceModel.Internal
{
	internal static class VirtualUtilities
	{
		public static string FormatVDir(string virtualDirectory)
		{
			Guard.ArgumentNotNullOrEmpty(virtualDirectory, "virtualDirectory");

			if (!virtualDirectory.StartsWith("~"))
			{
				if (!virtualDirectory.StartsWith("/"))
					virtualDirectory = "/" + virtualDirectory;
				virtualDirectory = "~" + virtualDirectory;
			}
			if (virtualDirectory.EndsWith("/"))
				virtualDirectory = virtualDirectory.TrimEnd("/".ToCharArray());
			virtualDirectory = virtualDirectory.ToLowerInvariant();

			return virtualDirectory;
		}
	}
}